package net.food.WxTemplate;

import net.sf.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/11 0011.
 */
public class Test {

    public  static  void main(String args[]){



        OrderInfoMode orderInfoMode=new OrderInfoMode();
        orderInfoMode.setFirst("您收到了一条新的订单。");
        orderInfoMode.setTradeDateTime("2014.41442");
        orderInfoMode.setOrderType("打印机订单");
        orderInfoMode.setCustomerInfo("商户");
        orderInfoMode.setOrderItemName("打印机型号");
        orderInfoMode.setOrderItemData("80-58MM");
        orderInfoMode.setRemark("你还有十个订单未处理");
        WechatTemplate wechatTemplate=new WechatTemplate();
        wechatTemplate.setTemplate_id("RSi_5SOLKxQv8NsjXObckubYf5_81h3HF3OTRb8ckqA");// 模板消息Id
        wechatTemplate.setTouser("o40NVwQmfrs-0T16-WQzv2hNnM94");//微信OPenid

        Map<String,TemplateData> data=new HashMap<String,TemplateData>();

        data.put("first",new TemplateData(orderInfoMode.getFirst(),"#173177"));
        data.put("tradeDateTime",new TemplateData(orderInfoMode.getTradeDateTime(),"#173177"));
        data.put("orderType",new TemplateData(orderInfoMode.getOrderType(),"#173177"));
        data.put("customerInfo",new TemplateData(orderInfoMode.getCustomerInfo(),"#173177"));
        data.put("orderItemName",new TemplateData(orderInfoMode.getOrderItemName(),"#173177"));
        data.put("orderItemData",new TemplateData(orderInfoMode.getOrderItemData(),"#173117"));
        data.put("remark",new TemplateData(orderInfoMode.getRemark(),"#173177"));

        wechatTemplate.setData(data);
        String weTemplate = JSONObject.fromObject(wechatTemplate).toString();
        System.out.println(weTemplate);
        String appId="***********";//Appid
        String appserct="*************"; //appserct
        AccessToken accessToken=TemplateUrl.getAccessToken(appId,appserct);
        JSONObject jsonObject=TemplateUrl.sendTmplMsg(wechatTemplate,accessToken.getAccessToken());
        System.out.println(jsonObject);

    }
}
